package com.sx.zongzhi.presenter;

import android.content.Context;

import com.sx.zongzhi.bean.HouseBean;
import com.sx.zongzhi.modle.CollectManager;
import com.sx.zongzhi.modle.HeadParamBean;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BasePageListBean;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.utils.BaseUtil;
import com.sx.zongzhi.view.IFactHouseView;

import java.util.Map;

/**实有房屋
 * Created by admin on 2017/12/12.
 */

public class FactHousePest {
    private IFactHouseView iFactHouseView;

    public FactHousePest(IFactHouseView iFactHouseView) {
        this.iFactHouseView=iFactHouseView;
    }

    public void getFactHouseList(Context context, int page, int rows) {
        Map<String,Object> map = HeadParamBean.getHead(context);
        map.put("page", page);
        map.put("rows", rows);
        map.put("searchVo.isBuilddatasId", false);//是否绑定
        new CollectManager().getFactHouseList(map, new BaseCallBack<BaseResult<BasePageListBean<HouseBean>>>() {
            @Override
            public void onSuccess(BaseResult<BasePageListBean<HouseBean>> response) {
                iFactHouseView.getFactHouseListSuccess(response.getData().permission,response.getData().rows,response.getData().getTotal());
            }
            @Override
            public void onFailures(String message) {
                iFactHouseView.showError(message);
            }
        });
    }

    /**
     * searchVo.orgId	否	string	组织机构主键
     searchVo.isRentalHouse	否	integer	是否是出租房(true:出租房,false:非出租房)
     searchVo.address	否	string	住房地址
     searchVo.name	否	string	房主姓名
     searchVo.nowLiveAddress	否	string	房主现居住地址
     searchVo.houseUses.id	否	string	房屋用途
     searchVo.houseAreaStart	否	double	建筑面积开始
     searchVo.houseAreaEnd	否	double	建筑面积结束
     */
    public void getFactHouseList(Context context, int page, int rows, Boolean isRentalHouse,String orgId,
                                 String address,String name,String nowLiveAddress,String houseUsesId,
                                 String houseAreaStart,String houseAreaEnd){
        Map<String,Object> map = HeadParamBean.getHead(context);
        map.put("page", page);
        map.put("rows", rows);
        if (!BaseUtil.isEmpty(orgId)){
            map.put("searchVo.orgId",orgId);
        }
        if (isRentalHouse != null){
            map.put("searchVo.isRentalHouse",isRentalHouse);
        }
        if (!BaseUtil.isEmpty(address)){
            map.put("searchVo.address",address);
        }
        if (!BaseUtil.isEmpty(name)){
            map.put("searchVo.name",name);
        }
        if (!BaseUtil.isEmpty(nowLiveAddress)){
            map.put("searchVo.nowLiveAddress",nowLiveAddress);
        }
        if (!BaseUtil.isEmpty(houseUsesId)){
            map.put("searchVo.houseUses.id",houseUsesId);
        }
        if (!BaseUtil.isEmpty(houseAreaStart)){
            map.put("searchVo.houseAreaStart",houseAreaStart);
        }
        if (!BaseUtil.isEmpty(houseAreaEnd)){
            map.put("searchVo.houseAreaEnd",houseAreaEnd);
        }
        new CollectManager().getFactHouseList(map, new BaseCallBack<BaseResult<BasePageListBean<HouseBean>>>() {
            @Override
            public void onSuccess(BaseResult<BasePageListBean<HouseBean>> response) {
                iFactHouseView.getFactHouseListSuccess(response.getData().permission,response.getData().rows,response.getData().getTotal());
            }
            @Override
            public void onFailures(String message) {
                iFactHouseView.showError(message);
            }
        });
    }
}
